package com.zhijian.warehouse.manage.controller;


import com.zhijian.response.annotation.Response;
import com.zhijian.warehouse.manage.entity.po.Dictionary;
import com.zhijian.warehouse.manage.entity.vo.request.DictionarySearchVo;
import com.zhijian.warehouse.manage.service.DictionaryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;
import java.util.Map;

/**
 * 字典表 控制层
 * @version: 1.0.1
 */
@Slf4j
@Controller
@Api(tags = "字典类")
public class DictionaryController {

    @Autowired
    private DictionaryService service;
    
    /**
     * 查询列表
     *
     * @param "data":["SCHOOL_CATEGORY","SCHOOL_TYPE"]
     * @return
     */
    @Response
    @PostMapping("/dictionary/map")
    @ApiOperation("根据名称查询")
    public Map<String, List<Dictionary>> selectByNames(@RequestBody(required=false) DictionarySearchVo param) {
        log.info("{} - {}| query info", this.getClass().getSimpleName(), param);
        if (param == null) {
            param = new DictionarySearchVo();
        }
        return service.selectByNames(param.getData());
    }
    
    /**
     * 刷新缓存
     * @param ids
     * @return
     */
    @Response
   // @PostMapping("/dictionary/restore")
    public boolean restoreCache() {
        log.info("{} - {}| restoreCache info", this.getClass().getSimpleName());
        return service.restoreCache();
    }
}
